﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SimpleMathGraphic
{
    public partial class MainWindow : Form
    {
        private void CoordinateSystem()
        {
            drawField.Image = new Bitmap(drawField.Width, drawField.Height);
            Graphics gr = Graphics.FromImage(drawField.Image);
            Pen pen = new Pen(Color.Black);
            //Рисуем оси
            int x1 = 0;
            int y1 = (int)drawField.Height / 2;
            int x2 = (int)drawField.Width;
            int y2 = y1;
            gr.DrawLine(pen, x1, y1, x2, y2);
            x1 = (int)drawField.Width / 2;
            y1 = 0;
            x2 = x1;
            y2 = (int)drawField.Height;
            gr.DrawLine(pen, x1, y1, x2, y2);
            //Рисуем стрелки
            x1 = (int)drawField.Width / 2;
            y1 = 0;
            x2 = (int)drawField.Width / 2 - drawField.Width / 40;
            y2 = (int)drawField.Height / 20;
            gr.DrawLine(pen, x1, y1, x2, y2);
            x1 = (int)drawField.Width / 2;
            y1 = 0;
            x2 = (int)drawField.Width / 2 + drawField.Width / 40;
            y2 = (int)drawField.Height / 20;
            gr.DrawLine(pen, x1, y1, x2, y2);
            x1 = (int)drawField.Width;
            y1 = (int)drawField.Height / 2;
            x2 = (int)drawField.Width - drawField.Width / 20;
            y2 = (int)drawField.Height / 2 - drawField.Height / 40;
            gr.DrawLine(pen, x1, y1, x2, y2);
            x1 = (int)drawField.Width;
            y1 = (int)drawField.Height / 2;
            x2 = (int)drawField.Width - drawField.Width / 20;
            y2 = (int)drawField.Height / 2 + drawField.Height / 40;
            gr.DrawLine(pen, x1, y1, x2, y2);
            //Рисуем риски
            x1 = (int)drawField.Width / 2 - drawField.Width / 20;
            y1 = (int)drawField.Height / 2 - drawField.Height / 50;
            y2 = (int)drawField.Height / 2 + drawField.Height / 50;
            while (x1 > 0)
            {
                gr.DrawLine(pen, x1, y1, x1, y2);
                x1 -= drawField.Width / 20;
            }
            x1 = (int)drawField.Width / 2 + drawField.Width / 20;
            while (x1 < drawField.Width - drawField.Width/20)
            {
                gr.DrawLine(pen, x1, y1, x1, y2);
                x1 += drawField.Width / 20;
            }
            x1 = (int)drawField.Width / 2 - drawField.Width / 50;
            x2 = (int)drawField.Width / 2 + drawField.Width / 50;
            y1 = (int)drawField.Height / 2 - drawField.Height / 20;
            
            while (y1 > 0)
            {
                gr.DrawLine(pen, x1, y1, x2, y1);
                y1 -= drawField.Height / 20;
            }
            y1 = (int)drawField.Height / 2 + drawField.Height / 20;

            while (y1 < drawField.Height-drawField.Height/20)
            {
                gr.DrawLine(pen, x1, y1, x2, y1);
                y1 += drawField.Height / 20;
            }
        }
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void MainWindow_Load(object sender, EventArgs e)
        {
            CoordinateSystem();
        }
    }
}
